package com.dlc.shop.systemtest.api.amount;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dlc.shop.combo.multishop.model.Combo;
import com.dlc.shop.common.util.Json;
import com.dlc.shop.systemtest.constants.Constant;
import com.dlc.shop.systemtest.util.HttpUtil;

import java.util.List;

/**
 * @author lpj
 */
public class ComboApi {

    /**
     * 分页查询套餐
     */
    public static List<Combo> getComboPage() {
        String url = Constant.SHOP_URL + "/shop/combo/page";
        return JSON.parseArray(JSON.toJSONString(Json.parseObject(JSON.toJSONString(HttpUtil.get(url, Page.class)), Page.class).getRecords()), Combo.class);
    }

    /**
     * 根据ID获取套餐信息
     */
    public static Combo getComboById(Long comboId) {
        String url = Constant.SHOP_URL + "/shop/combo/info/" + comboId;
        return HttpUtil.get(url, Combo.class);
    }

    /**
     * 新增套餐
     */
    public static void saveCombo(Combo combo) {
        String url = Constant.SHOP_URL + "/shop/combo";
        HttpUtil.post(url, combo);
    }

    /**
     * 修改套餐
     */
    public static void updateCombo(Combo combo) {
        String url = Constant.SHOP_URL + "/shop/combo";
        HttpUtil.put(url, combo);
    }

    /**
     * 修改套餐状态（失效/刪除套餐）
     */
    public static void updateComboStatus(Integer status, Long comboId) {
        String url = Constant.SHOP_URL + "/shop/combo/changeStatus?status=" + status + "&comboId=" + comboId;
        HttpUtil.put(url);
    }



}
